package com.example.bms.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.bms.entity.ApiResult;
import com.example.bms.serviceimpl.AnswerServiceImpl;
import com.example.bms.util.ApiResultHandler;
import com.example.bms.vo.AnswerVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @apiNote 查询所有的题库
 * @author 牛煜翔
 * @email 2837136899@qq.com
 * @since 1.0.0
 */
@RestController
@CrossOrigin(origins = "*", methods = {RequestMethod.GET, RequestMethod.POST,RequestMethod.PUT,RequestMethod.DELETE})
public class AnswerController {

    @Autowired
    private AnswerServiceImpl answerService;


    /**
     * @apiNote 查询所有的题库
     * @param page 页数
     * @param size 条数
     * @author 牛煜翔
     * @email 2837136899@qq.com
     * @return ApiResult
     * @since 1.0.0
     */
    @GetMapping("/answers/{page}/{size}")
    public ApiResult findAllQuestion(@PathVariable("page") Integer page, @PathVariable("size") Integer size){
       Page<AnswerVO> answerVOPage = new Page<AnswerVO>(page,size);
       IPage<AnswerVO> answerVOIPage = answerService.findAll(answerVOPage);
       return ApiResultHandler.buildApiResult(200,"查询所有题库",answerVOIPage);

    }
}
